-- assist_prop
-- create by panyl
-- 光环属性

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    clear = function(who, prop)
        local assist_data = who.dbase:queryTemp("assist_data", {});
        who.dbase:setTemp("assist_data", assist_data);

        local key = string.format("%s:%d", prop[2], prop[3]);
        assist_data[key] = nil;

        -- 更新下光环
        AssistMonsterM.updateAssistData();
    end,

    record = function(target, prop, path)
        -- 先赋属性
        local v = target.dbase:queryTemp("prop", path, {});
        table.insert(v, prop);
        target.dbase:setTemp("prop", path, v);

        -- 记录下来
        local assist_data = target.dbase:queryTemp("assist_data", {});
        target.dbase:setTemp("assist_data", assist_data);

        local key = string.format("%s:%d", prop[2], prop[3]);
        assist_data[key] = prop;

        -- 如果怪物死亡了
        if target:isDead() then
            return true;
        end

        -- 格子还未翻开
        local pos = target:getPos();
        local grid = DungeonM.getGridByPos(pos);
        if not grid or not grid:isOpened() then
            return true;
        end

        -- 更新下
        AssistMonsterM.updateAssistData();

        return true;
    end
};
